
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Porting your apps from Django 0.96 to 1.0 &#8212; Django 1.11.22.dev20190603194737 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Django version 0.96 release notes" href="0.96.html" />
    <link rel="prev" title="Django 1.0 release notes" href="1.0.html" />



 
<script type="text/javascript" src="../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../index.html">Django 1.11.22.dev20190603194737 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../index.html">Home</a>  |
        <a title="Table of contents" href="../contents.html">Table of contents</a>  |
        <a title="Global index" href="../genindex.html">Index</a>  |
        <a title="Module index" href="../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="1.0.html" title="Django 1.0 release notes">previous</a>
     |
    <a href="index.html" title="Release notes" accesskey="U">up</a>
   |
    <a href="0.96.html" title="Django version 0.96 release notes">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="releases-1.0-porting-guide">
            
  <div class="section" id="s-porting-your-apps-from-django-0-96-to-1-0">
<span id="porting-your-apps-from-django-0-96-to-1-0"></span><h1>Porting your apps from Django 0.96 to 1.0<a class="headerlink" href="#porting-your-apps-from-django-0-96-to-1-0" title="Permalink to this headline">¶</a></h1>
<p>Django 1.0 breaks compatibility with 0.96 in some areas.</p>
<p>This guide will help you port 0.96 projects and apps to 1.0. The first part of
this document includes the common changes needed to run with 1.0. If after going
through the first part your code still breaks, check the section <a class="reference internal" href="#less-common-changes">Less-common
Changes</a> for a list of a bunch of less-common compatibility issues.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last">The <a class="reference internal" href="1.0.html"><span class="doc">1.0 release notes</span></a>. That document explains the new
features in 1.0 more deeply; the porting guide is more concerned with
helping you quickly update your code.</p>
</div>
<div class="section" id="s-common-changes">
<span id="common-changes"></span><h2>Common changes<a class="headerlink" href="#common-changes" title="Permalink to this headline">¶</a></h2>
<p>This section describes the changes between 0.96 and 1.0 that most users will
need to make.</p>
<div class="section" id="s-use-unicode">
<span id="use-unicode"></span><h3>Use Unicode<a class="headerlink" href="#use-unicode" title="Permalink to this headline">¶</a></h3>
<p>Change string literals (<code class="docutils literal notranslate"><span class="pre">'foo'</span></code>) into Unicode literals (<code class="docutils literal notranslate"><span class="pre">u'foo'</span></code>). Django
now uses Unicode strings throughout. In most places, raw strings will continue
to work, but updating to use Unicode literals will prevent some obscure
problems.</p>
<p>See <a class="reference internal" href="../ref/unicode.html"><span class="doc">Unicode data</span></a> for full details.</p>
</div>
<div class="section" id="s-models">
<span id="models"></span><h3>Models<a class="headerlink" href="#models" title="Permalink to this headline">¶</a></h3>
<p>Common changes to your models file:</p>
<div class="section" id="s-rename-maxlength-to-max-length">
<span id="rename-maxlength-to-max-length"></span><h4>Rename <code class="docutils literal notranslate"><span class="pre">maxlength</span></code> to <code class="docutils literal notranslate"><span class="pre">max_length</span></code><a class="headerlink" href="#rename-maxlength-to-max-length" title="Permalink to this headline">¶</a></h4>
<p>Rename your <code class="docutils literal notranslate"><span class="pre">maxlength</span></code> argument to <code class="docutils literal notranslate"><span class="pre">max_length</span></code> (this was changed to be
consistent with form fields):</p>
</div>
<div class="section" id="s-replace-str-with-unicode">
<span id="replace-str-with-unicode"></span><h4>Replace <code class="docutils literal notranslate"><span class="pre">__str__</span></code> with <code class="docutils literal notranslate"><span class="pre">__unicode__</span></code><a class="headerlink" href="#replace-str-with-unicode" title="Permalink to this headline">¶</a></h4>
<p>Replace your model’s <code class="docutils literal notranslate"><span class="pre">__str__</span></code> function with a <code class="docutils literal notranslate"><span class="pre">__unicode__</span></code> method, and
make sure you <a class="reference internal" href="#use-unicode">use Unicode</a> (<code class="docutils literal notranslate"><span class="pre">u'foo'</span></code>) in that method.</p>
</div>
<div class="section" id="s-remove-prepopulated-from">
<span id="remove-prepopulated-from"></span><h4>Remove <code class="docutils literal notranslate"><span class="pre">prepopulated_from</span></code><a class="headerlink" href="#remove-prepopulated-from" title="Permalink to this headline">¶</a></h4>
<p>Remove the <code class="docutils literal notranslate"><span class="pre">prepopulated_from</span></code> argument on model fields. It’s no longer valid
and has been moved to the <code class="docutils literal notranslate"><span class="pre">ModelAdmin</span></code> class in <code class="docutils literal notranslate"><span class="pre">admin.py</span></code>. See <a class="reference internal" href="#the-admin">the
admin</a>, below, for more details about changes to the admin.</p>
</div>
<div class="section" id="s-remove-core">
<span id="remove-core"></span><h4>Remove <code class="docutils literal notranslate"><span class="pre">core</span></code><a class="headerlink" href="#remove-core" title="Permalink to this headline">¶</a></h4>
<p>Remove the <code class="docutils literal notranslate"><span class="pre">core</span></code> argument from your model fields. It is no longer
necessary, since the equivalent functionality (part of <a class="reference internal" href="../ref/contrib/admin/index.html#admin-inlines"><span class="std std-ref">inline editing</span></a>) is handled differently by the admin interface now. You don’t
have to worry about inline editing until you get to <a class="reference internal" href="#the-admin">the admin</a> section,
below. For now, remove all references to <code class="docutils literal notranslate"><span class="pre">core</span></code>.</p>
</div>
<div class="section" id="s-replace-class-admin-with-admin-py">
<span id="replace-class-admin-with-admin-py"></span><h4>Replace <code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">Admin:</span></code> with <code class="docutils literal notranslate"><span class="pre">admin.py</span></code><a class="headerlink" href="#replace-class-admin-with-admin-py" title="Permalink to this headline">¶</a></h4>
<p>Remove all your inner <code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">Admin</span></code> declarations from your models. They won’t
break anything if you leave them, but they also won’t do anything. To register
apps with the admin you’ll move those declarations to an <code class="docutils literal notranslate"><span class="pre">admin.py</span></code> file;
see <a class="reference internal" href="#the-admin">the admin</a> below for more details.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last">A contributor to <a class="reference external" href="https://www.djangosnippets.org/">djangosnippets</a> has written a script that’ll <a class="reference external" href="https://www.djangosnippets.org/snippets/603/">scan your
models.py and generate a corresponding admin.py</a>.</p>
</div>
</div>
<div class="section" id="s-example">
<span id="example"></span><h4>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h4>
<p>Below is an example <code class="docutils literal notranslate"><span class="pre">models.py</span></code> file with all the changes you’ll need to make:</p>
<p>Old (0.96) <code class="docutils literal notranslate"><span class="pre">models.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Author</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">first_name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">maxlength</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
    <span class="n">last_name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">maxlength</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
    <span class="n">slug</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">maxlength</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> <span class="n">prepopulate_from</span><span class="o">=</span><span class="p">(</span><span class="s1">&#39;first_name&#39;</span><span class="p">,</span> <span class="s1">&#39;last_name&#39;</span><span class="p">))</span>

    <span class="k">class</span> <span class="nc">Admin</span><span class="p">:</span>
        <span class="n">list_display</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;first_name&#39;</span><span class="p">,</span> <span class="s1">&#39;last_name&#39;</span><span class="p">]</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">first_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">last_name</span><span class="p">)</span>
</pre></div>
</div>
<p>New (1.0) <code class="docutils literal notranslate"><span class="pre">models.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Author</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">first_name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
    <span class="n">last_name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
    <span class="n">slug</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">60</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__unicode__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="sa">u</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">first_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">last_name</span><span class="p">)</span>
</pre></div>
</div>
<p>New (1.0) <code class="docutils literal notranslate"><span class="pre">admin.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.contrib</span> <span class="kn">import</span> <span class="n">admin</span>
<span class="kn">from</span> <span class="nn">models</span> <span class="kn">import</span> <span class="n">Author</span>

<span class="k">class</span> <span class="nc">AuthorAdmin</span><span class="p">(</span><span class="n">admin</span><span class="o">.</span><span class="n">ModelAdmin</span><span class="p">):</span>
    <span class="n">list_display</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;first_name&#39;</span><span class="p">,</span> <span class="s1">&#39;last_name&#39;</span><span class="p">]</span>
    <span class="n">prepopulated_fields</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s1">&#39;slug&#39;</span><span class="p">:</span> <span class="p">(</span><span class="s1">&#39;first_name&#39;</span><span class="p">,</span> <span class="s1">&#39;last_name&#39;</span><span class="p">)</span>
    <span class="p">}</span>

<span class="n">admin</span><span class="o">.</span><span class="n">site</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">Author</span><span class="p">,</span> <span class="n">AuthorAdmin</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="s-the-admin">
<span id="the-admin"></span><h3>The Admin<a class="headerlink" href="#the-admin" title="Permalink to this headline">¶</a></h3>
<p>One of the biggest changes in 1.0 is the new admin. The Django administrative
interface (<code class="docutils literal notranslate"><span class="pre">django.contrib.admin</span></code>) has been completely refactored; admin
definitions are now completely decoupled from model definitions, the framework
has been rewritten to use Django’s new form-handling library and redesigned with
extensibility and customization in mind.</p>
<p>Practically, this means you’ll need to rewrite all of your <code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">Admin</span></code>
declarations. You’ve already seen in <a class="reference internal" href="#models">models</a> above how to replace your <code class="docutils literal notranslate"><span class="pre">class</span>
<span class="pre">Admin</span></code> with a <code class="docutils literal notranslate"><span class="pre">admin.site.register()</span></code> call in an <code class="docutils literal notranslate"><span class="pre">admin.py</span></code> file. Below are
some more details on how to rewrite that <code class="docutils literal notranslate"><span class="pre">Admin</span></code> declaration into the new
syntax.</p>
<div class="section" id="s-use-new-inline-syntax">
<span id="use-new-inline-syntax"></span><h4>Use new inline syntax<a class="headerlink" href="#use-new-inline-syntax" title="Permalink to this headline">¶</a></h4>
<p>The new <code class="docutils literal notranslate"><span class="pre">edit_inline</span></code> options have all been moved to <code class="docutils literal notranslate"><span class="pre">admin.py</span></code>. Here’s an
example:</p>
<p>Old (0.96):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Parent</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="o">...</span>

<span class="k">class</span> <span class="nc">Child</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">parent</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">(</span><span class="n">Parent</span><span class="p">,</span> <span class="n">edit_inline</span><span class="o">=</span><span class="n">models</span><span class="o">.</span><span class="n">STACKED</span><span class="p">,</span> <span class="n">num_in_admin</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
</pre></div>
</div>
<p>New (1.0):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">ChildInline</span><span class="p">(</span><span class="n">admin</span><span class="o">.</span><span class="n">StackedInline</span><span class="p">):</span>
    <span class="n">model</span> <span class="o">=</span> <span class="n">Child</span>
    <span class="n">extra</span> <span class="o">=</span> <span class="mi">3</span>

<span class="k">class</span> <span class="nc">ParentAdmin</span><span class="p">(</span><span class="n">admin</span><span class="o">.</span><span class="n">ModelAdmin</span><span class="p">):</span>
    <span class="n">model</span> <span class="o">=</span> <span class="n">Parent</span>
    <span class="n">inlines</span> <span class="o">=</span> <span class="p">[</span><span class="n">ChildInline</span><span class="p">]</span>

<span class="n">admin</span><span class="o">.</span><span class="n">site</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">Parent</span><span class="p">,</span> <span class="n">ParentAdmin</span><span class="p">)</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="../ref/contrib/admin/index.html#admin-inlines"><span class="std std-ref">InlineModelAdmin objects</span></a> for more details.</p>
</div>
<div class="section" id="s-simplify-fields-or-use-fieldsets">
<span id="simplify-fields-or-use-fieldsets"></span><h4>Simplify <code class="docutils literal notranslate"><span class="pre">fields</span></code>, or use <code class="docutils literal notranslate"><span class="pre">fieldsets</span></code><a class="headerlink" href="#simplify-fields-or-use-fieldsets" title="Permalink to this headline">¶</a></h4>
<p>The old <code class="docutils literal notranslate"><span class="pre">fields</span></code> syntax was quite confusing, and has been simplified. The old
syntax still works, but you’ll need to use <code class="docutils literal notranslate"><span class="pre">fieldsets</span></code> instead.</p>
<p>Old (0.96):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">ModelOne</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="o">...</span>

    <span class="k">class</span> <span class="nc">Admin</span><span class="p">:</span>
        <span class="n">fields</span> <span class="o">=</span> <span class="p">(</span>
            <span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;fields&#39;</span><span class="p">:</span> <span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span><span class="s1">&#39;bar&#39;</span><span class="p">)}),</span>
        <span class="p">)</span>

<span class="k">class</span> <span class="nc">ModelTwo</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="o">...</span>

    <span class="k">class</span> <span class="nc">Admin</span><span class="p">:</span>
        <span class="n">fields</span> <span class="o">=</span> <span class="p">(</span>
            <span class="p">(</span><span class="s1">&#39;group1&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;fields&#39;</span><span class="p">:</span> <span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span><span class="s1">&#39;bar&#39;</span><span class="p">),</span>   <span class="s1">&#39;classes&#39;</span><span class="p">:</span> <span class="s1">&#39;collapse&#39;</span><span class="p">}),</span>
            <span class="p">(</span><span class="s1">&#39;group2&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;fields&#39;</span><span class="p">:</span> <span class="p">(</span><span class="s1">&#39;spam&#39;</span><span class="p">,</span><span class="s1">&#39;eggs&#39;</span><span class="p">),</span> <span class="s1">&#39;classes&#39;</span><span class="p">:</span> <span class="s1">&#39;collapse wide&#39;</span><span class="p">}),</span>
        <span class="p">)</span>
</pre></div>
</div>
<p>New (1.0):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">ModelOneAdmin</span><span class="p">(</span><span class="n">admin</span><span class="o">.</span><span class="n">ModelAdmin</span><span class="p">):</span>
    <span class="n">fields</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span> <span class="s1">&#39;bar&#39;</span><span class="p">)</span>

<span class="k">class</span> <span class="nc">ModelTwoAdmin</span><span class="p">(</span><span class="n">admin</span><span class="o">.</span><span class="n">ModelAdmin</span><span class="p">):</span>
    <span class="n">fieldsets</span> <span class="o">=</span> <span class="p">(</span>
        <span class="p">(</span><span class="s1">&#39;group1&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;fields&#39;</span><span class="p">:</span> <span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span><span class="s1">&#39;bar&#39;</span><span class="p">),</span>   <span class="s1">&#39;classes&#39;</span><span class="p">:</span> <span class="s1">&#39;collapse&#39;</span><span class="p">}),</span>
        <span class="p">(</span><span class="s1">&#39;group2&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;fields&#39;</span><span class="p">:</span> <span class="p">(</span><span class="s1">&#39;spam&#39;</span><span class="p">,</span><span class="s1">&#39;eggs&#39;</span><span class="p">),</span> <span class="s1">&#39;classes&#39;</span><span class="p">:</span> <span class="s1">&#39;collapse wide&#39;</span><span class="p">}),</span>
    <span class="p">)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<ul class="last simple">
<li>More detailed information about the changes and the reasons behind them
can be found on the <a class="reference external" href="https://code.djangoproject.com/wiki/NewformsAdminBranch">NewformsAdminBranch wiki page</a></li>
<li>The new admin comes with a ton of new features; you can read about them in
the <a class="reference internal" href="../ref/contrib/admin/index.html"><span class="doc">admin documentation</span></a>.</li>
</ul>
</div>
</div>
</div>
<div class="section" id="s-urls">
<span id="urls"></span><h3>URLs<a class="headerlink" href="#urls" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-update-your-root-urls-py">
<span id="update-your-root-urls-py"></span><h4>Update your root <code class="docutils literal notranslate"><span class="pre">urls.py</span></code><a class="headerlink" href="#update-your-root-urls-py" title="Permalink to this headline">¶</a></h4>
<p>If you’re using the admin site, you need to update your root <code class="docutils literal notranslate"><span class="pre">urls.py</span></code>.</p>
<p>Old (0.96) <code class="docutils literal notranslate"><span class="pre">urls.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.conf.urls.defaults</span> <span class="kn">import</span> <span class="o">*</span>

<span class="n">urlpatterns</span> <span class="o">=</span> <span class="n">patterns</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
    <span class="p">(</span><span class="sa">r</span><span class="s1">&#39;^admin/&#39;</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s1">&#39;django.contrib.admin.urls&#39;</span><span class="p">)),</span>

    <span class="c1"># ... the rest of your URLs here ...</span>
<span class="p">)</span>
</pre></div>
</div>
<p>New (1.0) <code class="docutils literal notranslate"><span class="pre">urls.py</span></code>:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.conf.urls.defaults</span> <span class="kn">import</span> <span class="o">*</span>

<span class="c1"># The next two lines enable the admin and load each admin.py file:</span>
<span class="kn">from</span> <span class="nn">django.contrib</span> <span class="kn">import</span> <span class="n">admin</span>
<span class="n">admin</span><span class="o">.</span><span class="n">autodiscover</span><span class="p">()</span>

<span class="n">urlpatterns</span> <span class="o">=</span> <span class="n">patterns</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
    <span class="p">(</span><span class="sa">r</span><span class="s1">&#39;^admin/(.*)&#39;</span><span class="p">,</span> <span class="n">admin</span><span class="o">.</span><span class="n">site</span><span class="o">.</span><span class="n">root</span><span class="p">),</span>

    <span class="c1"># ... the rest of your URLs here ...</span>
<span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="s-views">
<span id="views"></span><h3>Views<a class="headerlink" href="#views" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-use-django-forms-instead-of-newforms">
<span id="use-django-forms-instead-of-newforms"></span><h4>Use <code class="docutils literal notranslate"><span class="pre">django.forms</span></code> instead of <code class="docutils literal notranslate"><span class="pre">newforms</span></code><a class="headerlink" href="#use-django-forms-instead-of-newforms" title="Permalink to this headline">¶</a></h4>
<p>Replace <code class="docutils literal notranslate"><span class="pre">django.newforms</span></code> with <code class="docutils literal notranslate"><span class="pre">django.forms</span></code> – Django 1.0 renamed the
<code class="docutils literal notranslate"><span class="pre">newforms</span></code> module (introduced in 0.96) to plain old <code class="docutils literal notranslate"><span class="pre">forms</span></code>. The
<code class="docutils literal notranslate"><span class="pre">oldforms</span></code> module was also removed.</p>
<p>If you’re already using the <code class="docutils literal notranslate"><span class="pre">newforms</span></code> library, and you used our recommended
<code class="docutils literal notranslate"><span class="pre">import</span></code> statement syntax, all you have to do is change your import
statements.</p>
<p>Old:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django</span> <span class="kn">import</span> <span class="n">newforms</span> <span class="k">as</span> <span class="n">forms</span>
</pre></div>
</div>
<p>New:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django</span> <span class="kn">import</span> <span class="n">forms</span>
</pre></div>
</div>
<p>If you’re using the old forms system (formerly known as <code class="docutils literal notranslate"><span class="pre">django.forms</span></code> and
<code class="docutils literal notranslate"><span class="pre">django.oldforms</span></code>), you’ll have to rewrite your forms. A good place to start
is the <a class="reference internal" href="../topics/forms/index.html"><span class="doc">forms documentation</span></a></p>
</div>
<div class="section" id="s-handle-uploaded-files-using-the-new-api">
<span id="handle-uploaded-files-using-the-new-api"></span><h4>Handle uploaded files using the new API<a class="headerlink" href="#handle-uploaded-files-using-the-new-api" title="Permalink to this headline">¶</a></h4>
<p>Replace use of uploaded files – that is, entries in <code class="docutils literal notranslate"><span class="pre">request.FILES</span></code> – as
simple dictionaries with the new
<a class="reference internal" href="../ref/files/uploads.html#django.core.files.uploadedfile.UploadedFile" title="django.core.files.uploadedfile.UploadedFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">UploadedFile</span></code></a>. The old dictionary
syntax no longer works.</p>
<p>Thus, in a view like:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">my_view</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
    <span class="n">f</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">FILES</span><span class="p">[</span><span class="s1">&#39;file_field_name&#39;</span><span class="p">]</span>
    <span class="o">...</span>
</pre></div>
</div>
<p>…you’d need to make the following changes:</p>
<table class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Old (0.96)</th>
<th class="head">New (1.0)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">f['content']</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">f.read()</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">f['filename']</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">f.name</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">f['content-type']</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">f.content_type</span></code></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="s-work-with-file-fields-using-the-new-api">
<span id="work-with-file-fields-using-the-new-api"></span><h4>Work with file fields using the new API<a class="headerlink" href="#work-with-file-fields-using-the-new-api" title="Permalink to this headline">¶</a></h4>
<p>The internal implementation of <a class="reference internal" href="../ref/models/fields.html#django.db.models.FileField" title="django.db.models.FileField"><code class="xref py py-class docutils literal notranslate"><span class="pre">django.db.models.FileField</span></code></a> have changed.
A visible result of this is that the way you access special attributes (URL,
filename, image size, etc.) of these model fields has changed. You will need to
make the following changes, assuming your model’s
<a class="reference internal" href="../ref/models/fields.html#django.db.models.FileField" title="django.db.models.FileField"><code class="xref py py-class docutils literal notranslate"><span class="pre">FileField</span></code></a> is called <code class="docutils literal notranslate"><span class="pre">myfile</span></code>:</p>
<table class="docutils">
<colgroup>
<col width="58%" />
<col width="42%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Old (0.96)</th>
<th class="head">New (1.0)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">myfile.get_content_filename()</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">myfile.content.path</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">myfile.get_content_url()</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">myfile.content.url</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">myfile.get_content_size()</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">myfile.content.size</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">myfile.save_content_file()</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">myfile.content.save()</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">myfile.get_content_width()</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">myfile.content.width</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">myfile.get_content_height()</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">myfile.content.height</span></code></td>
</tr>
</tbody>
</table>
<p>Note that the <code class="docutils literal notranslate"><span class="pre">width</span></code> and <code class="docutils literal notranslate"><span class="pre">height</span></code> attributes only make sense for
<a class="reference internal" href="../ref/models/fields.html#django.db.models.ImageField" title="django.db.models.ImageField"><code class="xref py py-class docutils literal notranslate"><span class="pre">ImageField</span></code></a> fields. More details can be found in the
<a class="reference internal" href="../ref/models/fields.html"><span class="doc">model API</span></a> documentation.</p>
</div>
<div class="section" id="s-use-paginator-instead-of-objectpaginator">
<span id="use-paginator-instead-of-objectpaginator"></span><h4>Use <code class="docutils literal notranslate"><span class="pre">Paginator</span></code> instead of <code class="docutils literal notranslate"><span class="pre">ObjectPaginator</span></code><a class="headerlink" href="#use-paginator-instead-of-objectpaginator" title="Permalink to this headline">¶</a></h4>
<p>The <code class="docutils literal notranslate"><span class="pre">ObjectPaginator</span></code> in 0.96 has been removed and replaced with an improved
version, <a class="reference internal" href="../topics/pagination.html#django.core.paginator.Paginator" title="django.core.paginator.Paginator"><code class="xref py py-class docutils literal notranslate"><span class="pre">django.core.paginator.Paginator</span></code></a>.</p>
</div>
</div>
<div class="section" id="s-templates">
<span id="templates"></span><h3>Templates<a class="headerlink" href="#templates" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-learn-to-love-autoescaping">
<span id="learn-to-love-autoescaping"></span><h4>Learn to love autoescaping<a class="headerlink" href="#learn-to-love-autoescaping" title="Permalink to this headline">¶</a></h4>
<p>By default, the template system now automatically HTML-escapes the output of
every variable. To learn more, see <a class="reference internal" href="../ref/templates/language.html#automatic-html-escaping"><span class="std std-ref">Automatic HTML escaping</span></a>.</p>
<p>To disable auto-escaping for an individual variable, use the <a class="reference internal" href="../ref/templates/builtins.html#std:templatefilter-safe"><code class="xref std std-tfilter docutils literal notranslate"><span class="pre">safe</span></code></a>
filter:</p>
<div class="highlight-html+django notranslate"><div class="highlight"><pre><span></span>This will be escaped: <span class="cp">{{</span> <span class="nv">data</span> <span class="cp">}}</span>
This will not be escaped: <span class="cp">{{</span> <span class="nv">data</span><span class="o">|</span><span class="nf">safe</span> <span class="cp">}}</span>
</pre></div>
</div>
<p>To disable auto-escaping for an entire template, wrap the template (or just a
particular section of the template) in the <a class="reference internal" href="../ref/templates/builtins.html#std:templatetag-autoescape"><code class="xref std std-ttag docutils literal notranslate"><span class="pre">autoescape</span></code></a> tag:</p>
<div class="highlight-html+django notranslate"><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">autoescape</span> <span class="nv">off</span> <span class="cp">%}</span>
   ... unescaped template content here ...
<span class="cp">{%</span> <span class="k">endautoescape</span> <span class="cp">%}</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="section" id="s-less-common-changes">
<span id="less-common-changes"></span><h2>Less-common changes<a class="headerlink" href="#less-common-changes" title="Permalink to this headline">¶</a></h2>
<p>The following changes are smaller, more localized changes. They should only
affect more advanced users, but it’s probably worth reading through the list and
checking your code for these things.</p>
<div class="section" id="s-signals">
<span id="signals"></span><h3>Signals<a class="headerlink" href="#signals" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>Add <code class="docutils literal notranslate"><span class="pre">**kwargs</span></code> to any registered signal handlers.</li>
<li>Connect, disconnect, and send signals via methods on the
<a class="reference internal" href="../topics/signals.html#django.dispatch.Signal" title="django.dispatch.Signal"><code class="xref py py-class docutils literal notranslate"><span class="pre">Signal</span></code></a> object instead of through module methods in
<code class="docutils literal notranslate"><span class="pre">django.dispatch.dispatcher</span></code>.</li>
<li>Remove any use of the <code class="docutils literal notranslate"><span class="pre">Anonymous</span></code> and <code class="docutils literal notranslate"><span class="pre">Any</span></code> sender options; they no longer
exist. You can still receive signals sent by any sender by using
<code class="docutils literal notranslate"><span class="pre">sender=None</span></code></li>
<li>Make any custom signals you’ve declared into instances of
<a class="reference internal" href="../topics/signals.html#django.dispatch.Signal" title="django.dispatch.Signal"><code class="xref py py-class docutils literal notranslate"><span class="pre">django.dispatch.Signal</span></code></a> instead of anonymous objects.</li>
</ul>
<p>Here’s quick summary of the code changes you’ll need to make:</p>
<table class="docutils">
<colgroup>
<col width="56%" />
<col width="44%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Old (0.96)</th>
<th class="head">New (1.0)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">def</span> <span class="pre">callback(sender)</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">def</span> <span class="pre">callback(sender,</span> <span class="pre">**kwargs)</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">sig</span> <span class="pre">=</span> <span class="pre">object()</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">sig</span> <span class="pre">=</span> <span class="pre">django.dispatch.Signal()</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">dispatcher.connect(callback,</span> <span class="pre">sig)</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">sig.connect(callback)</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">dispatcher.send(sig,</span> <span class="pre">sender)</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">sig.send(sender)</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">dispatcher.connect(callback,</span> <span class="pre">sig,</span> <span class="pre">sender=Any)</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">sig.connect(callback,</span> <span class="pre">sender=None)</span></code></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="s-comments">
<span id="comments"></span><h3>Comments<a class="headerlink" href="#comments" title="Permalink to this headline">¶</a></h3>
<p>If you were using Django 0.96’s <code class="docutils literal notranslate"><span class="pre">django.contrib.comments</span></code> app, you’ll need to
upgrade to the new comments app introduced in 1.0. See the upgrade guide
for details.</p>
</div>
<div class="section" id="s-template-tags">
<span id="template-tags"></span><h3>Template tags<a class="headerlink" href="#template-tags" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-spaceless-tag">
<span id="spaceless-tag"></span><h4><a class="reference internal" href="../ref/templates/builtins.html#std:templatetag-spaceless"><code class="xref std std-ttag docutils literal notranslate"><span class="pre">spaceless</span></code></a> tag<a class="headerlink" href="#spaceless-tag" title="Permalink to this headline">¶</a></h4>
<p>The spaceless template tag now removes <em>all</em> spaces between HTML tags, instead
of preserving a single space.</p>
</div>
</div>
<div class="section" id="s-local-flavors">
<span id="local-flavors"></span><h3>Local flavors<a class="headerlink" href="#local-flavors" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-u-s-local-flavor">
<span id="u-s-local-flavor"></span><h4>U.S. local flavor<a class="headerlink" href="#u-s-local-flavor" title="Permalink to this headline">¶</a></h4>
<p><code class="docutils literal notranslate"><span class="pre">django.contrib.localflavor.usa</span></code> has been renamed to
<code class="docutils literal notranslate"><span class="pre">django.contrib.localflavor.us</span></code>. This change was made to match the naming
scheme of other local flavors. To migrate your code, all you need to do is
change the imports.</p>
</div>
</div>
<div class="section" id="s-sessions">
<span id="sessions"></span><h3>Sessions<a class="headerlink" href="#sessions" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-getting-a-new-session-key">
<span id="getting-a-new-session-key"></span><h4>Getting a new session key<a class="headerlink" href="#getting-a-new-session-key" title="Permalink to this headline">¶</a></h4>
<p><code class="docutils literal notranslate"><span class="pre">SessionBase.get_new_session_key()</span></code> has been renamed to
<code class="docutils literal notranslate"><span class="pre">_get_new_session_key()</span></code>. <code class="docutils literal notranslate"><span class="pre">get_new_session_object()</span></code> no longer exists.</p>
</div>
</div>
<div class="section" id="s-fixtures">
<span id="fixtures"></span><h3>Fixtures<a class="headerlink" href="#fixtures" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-loading-a-row-no-longer-calls-save">
<span id="loading-a-row-no-longer-calls-save"></span><h4>Loading a row no longer calls <code class="docutils literal notranslate"><span class="pre">save()</span></code><a class="headerlink" href="#loading-a-row-no-longer-calls-save" title="Permalink to this headline">¶</a></h4>
<p>Previously, loading a row automatically ran the model’s <code class="docutils literal notranslate"><span class="pre">save()</span></code> method. This
is no longer the case, so any fields (for example: timestamps) that were
auto-populated by a <code class="docutils literal notranslate"><span class="pre">save()</span></code> now need explicit values in any fixture.</p>
</div>
</div>
<div class="section" id="s-settings">
<span id="settings"></span><h3>Settings<a class="headerlink" href="#settings" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-better-exceptions">
<span id="better-exceptions"></span><h4>Better exceptions<a class="headerlink" href="#better-exceptions" title="Permalink to this headline">¶</a></h4>
<p>The old <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#EnvironmentError" title="(in Python v3.7)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">EnvironmentError</span></code></a> has split into an
<a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ImportError" title="(in Python v3.7)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a> when Django fails to find the settings module
and a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#RuntimeError" title="(in Python v3.7)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">RuntimeError</span></code></a> when you try to reconfigure settings
after having already used them.</p>
</div>
<div class="section" id="s-login-url-has-moved">
<span id="login-url-has-moved"></span><h4><a class="reference internal" href="../ref/settings.html#std:setting-LOGIN_URL"><code class="xref std std-setting docutils literal notranslate"><span class="pre">LOGIN_URL</span></code></a> has moved<a class="headerlink" href="#login-url-has-moved" title="Permalink to this headline">¶</a></h4>
<p>The <a class="reference internal" href="../ref/settings.html#std:setting-LOGIN_URL"><code class="xref std std-setting docutils literal notranslate"><span class="pre">LOGIN_URL</span></code></a> constant moved from <code class="docutils literal notranslate"><span class="pre">django.contrib.auth</span></code> into the
<code class="docutils literal notranslate"><span class="pre">settings</span></code> module. Instead of using <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">django.contrib.auth</span> <span class="pre">import</span>
<span class="pre">LOGIN_URL</span></code> refer to <a class="reference internal" href="../ref/settings.html#std:setting-LOGIN_URL"><code class="xref std std-setting docutils literal notranslate"><span class="pre">settings.LOGIN_URL</span></code></a>.</p>
</div>
<div class="section" id="s-append-slash-behavior-has-been-updated">
<span id="append-slash-behavior-has-been-updated"></span><h4><a class="reference internal" href="../ref/settings.html#std:setting-APPEND_SLASH"><code class="xref std std-setting docutils literal notranslate"><span class="pre">APPEND_SLASH</span></code></a> behavior has been updated<a class="headerlink" href="#append-slash-behavior-has-been-updated" title="Permalink to this headline">¶</a></h4>
<p>In 0.96, if a URL didn’t end in a slash or have a period in the final
component of its path, and <a class="reference internal" href="../ref/settings.html#std:setting-APPEND_SLASH"><code class="xref std std-setting docutils literal notranslate"><span class="pre">APPEND_SLASH</span></code></a> was True, Django would
redirect to the same URL, but with a slash appended to the end. Now, Django
checks to see whether the pattern without the trailing slash would be matched
by something in your URL patterns. If so, no redirection takes place, because
it is assumed you deliberately wanted to catch that pattern.</p>
<p>For most people, this won’t require any changes. Some people, though, have URL
patterns that look like this:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="sa">r</span><span class="s1">&#39;/some_prefix/(.*)$&#39;</span>
</pre></div>
</div>
<p>Previously, those patterns would have been redirected to have a trailing
slash. If you always want a slash on such URLs, rewrite the pattern as:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="sa">r</span><span class="s1">&#39;/some_prefix/(.*/)$&#39;</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="s-smaller-model-changes">
<span id="smaller-model-changes"></span><h3>Smaller model changes<a class="headerlink" href="#smaller-model-changes" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-different-exception-from-get">
<span id="different-exception-from-get"></span><h4>Different exception from <code class="docutils literal notranslate"><span class="pre">get()</span></code><a class="headerlink" href="#different-exception-from-get" title="Permalink to this headline">¶</a></h4>
<p>Managers now return a <a class="reference internal" href="../ref/exceptions.html#django.core.exceptions.MultipleObjectsReturned" title="django.core.exceptions.MultipleObjectsReturned"><code class="xref py py-exc docutils literal notranslate"><span class="pre">MultipleObjectsReturned</span></code></a>
exception instead of <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#AssertionError" title="(in Python v3.7)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">AssertionError</span></code></a>:</p>
<p>Old (0.96):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
    <span class="n">Model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">AssertionError</span><span class="p">:</span>
    <span class="n">handle_the_error</span><span class="p">()</span>
</pre></div>
</div>
<p>New (1.0):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
    <span class="n">Model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="o">...</span><span class="p">)</span>
<span class="k">except</span> <span class="n">Model</span><span class="o">.</span><span class="n">MultipleObjectsReturned</span><span class="p">:</span>
    <span class="n">handle_the_error</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="s-lazydate-has-been-fired">
<span id="lazydate-has-been-fired"></span><h4><code class="docutils literal notranslate"><span class="pre">LazyDate</span></code> has been fired<a class="headerlink" href="#lazydate-has-been-fired" title="Permalink to this headline">¶</a></h4>
<p>The <code class="docutils literal notranslate"><span class="pre">LazyDate</span></code> helper class no longer exists.</p>
<p>Default field values and query arguments can both be callable objects, so
instances of <code class="docutils literal notranslate"><span class="pre">LazyDate</span></code> can be replaced with a reference to <code class="docutils literal notranslate"><span class="pre">datetime.datetime.now</span></code>:</p>
<p>Old (0.96):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Article</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">title</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">maxlength</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
    <span class="n">published</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">DateField</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="n">LazyDate</span><span class="p">())</span>
</pre></div>
</div>
<p>New (1.0):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">datetime</span>

<span class="k">class</span> <span class="nc">Article</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">title</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
    <span class="n">published</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">DateField</span><span class="p">(</span><span class="n">default</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="s-decimalfield-is-new-and-floatfield-is-now-a-proper-float">
<span id="decimalfield-is-new-and-floatfield-is-now-a-proper-float"></span><h4><code class="docutils literal notranslate"><span class="pre">DecimalField</span></code> is new, and <code class="docutils literal notranslate"><span class="pre">FloatField</span></code> is now a proper float<a class="headerlink" href="#decimalfield-is-new-and-floatfield-is-now-a-proper-float" title="Permalink to this headline">¶</a></h4>
<p>Old (0.96):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyModel</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">field_name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">FloatField</span><span class="p">(</span><span class="n">max_digits</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">decimal_places</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
    <span class="o">...</span>
</pre></div>
</div>
<p>New (1.0):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyModel</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">field_name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">DecimalField</span><span class="p">(</span><span class="n">max_digits</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">decimal_places</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
    <span class="o">...</span>
</pre></div>
</div>
<p>If you forget to make this change, you will see errors about <code class="docutils literal notranslate"><span class="pre">FloatField</span></code>
not taking a <code class="docutils literal notranslate"><span class="pre">max_digits</span></code> attribute in <code class="docutils literal notranslate"><span class="pre">__init__</span></code>, because the new
<code class="docutils literal notranslate"><span class="pre">FloatField</span></code> takes no precision-related arguments.</p>
<p>If you’re using MySQL or PostgreSQL, no further changes are needed. The
database column types for <code class="docutils literal notranslate"><span class="pre">DecimalField</span></code> are the same as for the old
<code class="docutils literal notranslate"><span class="pre">FloatField</span></code>.</p>
<p>If you’re using SQLite, you need to force the database to view the
appropriate columns as decimal types, rather than floats. To do this, you’ll
need to reload your data. Do this after you have made the change to using
<code class="docutils literal notranslate"><span class="pre">DecimalField</span></code> in your code and updated the Django code.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p><strong>Back up your database first!</strong></p>
<p class="last">For SQLite, this means making a copy of the single file that stores the
database (the name of that file is the <code class="docutils literal notranslate"><span class="pre">DATABASE_NAME</span></code> in your
settings.py file).</p>
</div>
<p>To upgrade each application to use a <code class="docutils literal notranslate"><span class="pre">DecimalField</span></code>, you can do the
following, replacing <code class="docutils literal notranslate"><span class="pre">&lt;app&gt;</span></code> in the code below with each app’s name:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> ./manage.py dumpdata --format<span class="o">=</span>xml &lt;app&gt; &gt; data-dump.xml
<span class="gp">$</span> ./manage.py reset &lt;app&gt;
<span class="gp">$</span> ./manage.py loaddata data-dump.xml
</pre></div>
</div>
<p>Notes:</p>
<ol class="arabic simple">
<li>It’s important that you remember to use XML format in the first step of
this process. We are exploiting a feature of the XML data dumps that makes
porting floats to decimals with SQLite possible.</li>
<li>In the second step you will be asked to confirm that you are prepared to
lose the data for the application(s) in question. Say yes; we’ll restore
this data in the third step, of course.</li>
<li><code class="docutils literal notranslate"><span class="pre">DecimalField</span></code> is not used in any of the apps shipped with Django prior
to this change being made, so you do not need to worry about performing
this procedure for any of the standard Django models.</li>
</ol>
<p>If something goes wrong in the above process, just copy your backed up
database file over the original file and start again.</p>
</div>
</div>
<div class="section" id="s-internationalization">
<span id="internationalization"></span><h3>Internationalization<a class="headerlink" href="#internationalization" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-django-views-i18n-set-language-now-requires-a-post-request">
<span id="django-views-i18n-set-language-now-requires-a-post-request"></span><h4><a class="reference internal" href="../topics/i18n/translation.html#django.views.i18n.set_language" title="django.views.i18n.set_language"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.views.i18n.set_language()</span></code></a> now requires a POST request<a class="headerlink" href="#django-views-i18n-set-language-now-requires-a-post-request" title="Permalink to this headline">¶</a></h4>
<p>Previously, a GET request was used. The old behavior meant that state (the
locale used to display the site) could be changed by a GET request, which is
against the HTTP specification’s recommendations. Code calling this view must
ensure that a POST request is now made, instead of a GET. This means you can
no longer use a link to access the view, but must use a form submission of
some kind (e.g. a button).</p>
</div>
<div class="section" id="s-is-no-longer-in-builtins">
<span id="is-no-longer-in-builtins"></span><h4><code class="docutils literal notranslate"><span class="pre">_()</span></code> is no longer in builtins<a class="headerlink" href="#is-no-longer-in-builtins" title="Permalink to this headline">¶</a></h4>
<p><code class="docutils literal notranslate"><span class="pre">_()</span></code> (the callable object whose name is a single underscore) is no longer
monkeypatched into builtins – that is, it’s no longer available magically in
every module.</p>
<p>If you were previously relying on <code class="docutils literal notranslate"><span class="pre">_()</span></code> always being present, you should now
explicitly import <code class="docutils literal notranslate"><span class="pre">ugettext</span></code> or <code class="docutils literal notranslate"><span class="pre">ugettext_lazy</span></code>, if appropriate, and alias
it to <code class="docutils literal notranslate"><span class="pre">_</span></code> yourself:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.utils.translation</span> <span class="kn">import</span> <span class="n">ugettext</span> <span class="k">as</span> <span class="n">_</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="s-http-request-response-objects">
<span id="http-request-response-objects"></span><h3>HTTP request/response objects<a class="headerlink" href="#http-request-response-objects" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-dictionary-access-to-httprequest">
<span id="dictionary-access-to-httprequest"></span><h4>Dictionary access to <code class="docutils literal notranslate"><span class="pre">HttpRequest</span></code><a class="headerlink" href="#dictionary-access-to-httprequest" title="Permalink to this headline">¶</a></h4>
<p><code class="docutils literal notranslate"><span class="pre">HttpRequest</span></code> objects no longer directly support dictionary-style
access; previously, both <code class="docutils literal notranslate"><span class="pre">GET</span></code> and <code class="docutils literal notranslate"><span class="pre">POST</span></code> data were directly
available on the <code class="docutils literal notranslate"><span class="pre">HttpRequest</span></code> object (e.g., you could check for a
piece of form data by using <code class="docutils literal notranslate"><span class="pre">if</span> <span class="pre">'some_form_key'</span> <span class="pre">in</span> <span class="pre">request</span></code> or by
reading <code class="docutils literal notranslate"><span class="pre">request['some_form_key']</span></code>. This is no longer supported; if
you need access to the combined <code class="docutils literal notranslate"><span class="pre">GET</span></code> and <code class="docutils literal notranslate"><span class="pre">POST</span></code> data, use
<code class="docutils literal notranslate"><span class="pre">request.REQUEST</span></code> instead.</p>
<p>It is strongly suggested, however, that you always explicitly look in
the appropriate dictionary for the type of request you expect to
receive (<code class="docutils literal notranslate"><span class="pre">request.GET</span></code> or <code class="docutils literal notranslate"><span class="pre">request.POST</span></code>); relying on the combined
<code class="docutils literal notranslate"><span class="pre">request.REQUEST</span></code> dictionary can mask the origin of incoming data.</p>
</div>
<div class="section" id="s-accessing-httpresponse-headers">
<span id="accessing-httpresponse-headers"></span><h4>Accessing <code class="docutils literal notranslate"><span class="pre">HTTPResponse</span></code> headers<a class="headerlink" href="#accessing-httpresponse-headers" title="Permalink to this headline">¶</a></h4>
<p><code class="docutils literal notranslate"><span class="pre">django.http.HttpResponse.headers</span></code> has been renamed to <code class="docutils literal notranslate"><span class="pre">_headers</span></code> and
<a class="reference internal" href="../ref/request-response.html#django.http.HttpResponse" title="django.http.HttpResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">HttpResponse</span></code></a> now supports containment checking directly.
So use <code class="docutils literal notranslate"><span class="pre">if</span> <span class="pre">header</span> <span class="pre">in</span> <span class="pre">response:</span></code> instead of <code class="docutils literal notranslate"><span class="pre">if</span> <span class="pre">header</span> <span class="pre">in</span> <span class="pre">response.headers:</span></code>.</p>
</div>
</div>
<div class="section" id="s-generic-relations">
<span id="generic-relations"></span><h3>Generic relations<a class="headerlink" href="#generic-relations" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-generic-relations-have-been-moved-out-of-core">
<span id="generic-relations-have-been-moved-out-of-core"></span><h4>Generic relations have been moved out of core<a class="headerlink" href="#generic-relations-have-been-moved-out-of-core" title="Permalink to this headline">¶</a></h4>
<p>The generic relation classes – <code class="docutils literal notranslate"><span class="pre">GenericForeignKey</span></code> and <code class="docutils literal notranslate"><span class="pre">GenericRelation</span></code>
– have moved into the <a class="reference internal" href="../ref/contrib/contenttypes.html#module-django.contrib.contenttypes" title="django.contrib.contenttypes: Provides generic interface to installed models."><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.contenttypes</span></code></a> module.</p>
</div>
</div>
<div class="section" id="s-testing">
<span id="testing"></span><h3>Testing<a class="headerlink" href="#testing" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-django-test-client-login-has-changed">
<span id="django-test-client-login-has-changed"></span><h4><a class="reference internal" href="../topics/testing/tools.html#django.test.Client.login" title="django.test.Client.login"><code class="xref py py-meth docutils literal notranslate"><span class="pre">django.test.Client.login()</span></code></a> has changed<a class="headerlink" href="#django-test-client-login-has-changed" title="Permalink to this headline">¶</a></h4>
<p>Old (0.96):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.test</span> <span class="kn">import</span> <span class="n">Client</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">Client</span><span class="p">()</span>
<span class="n">c</span><span class="o">.</span><span class="n">login</span><span class="p">(</span><span class="s1">&#39;/path/to/login&#39;</span><span class="p">,</span><span class="s1">&#39;myuser&#39;</span><span class="p">,</span><span class="s1">&#39;mypassword&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>New (1.0):</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># ... same as above, but then:</span>
<span class="n">c</span><span class="o">.</span><span class="n">login</span><span class="p">(</span><span class="n">username</span><span class="o">=</span><span class="s1">&#39;myuser&#39;</span><span class="p">,</span> <span class="n">password</span><span class="o">=</span><span class="s1">&#39;mypassword&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="s-management-commands">
<span id="management-commands"></span><h3>Management commands<a class="headerlink" href="#management-commands" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-running-management-commands-from-your-code">
<span id="running-management-commands-from-your-code"></span><h4>Running management commands from your code<a class="headerlink" href="#running-management-commands-from-your-code" title="Permalink to this headline">¶</a></h4>
<p><a class="reference internal" href="../howto/custom-management-commands.html#module-django.core.management" title="django.core.management"><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.core.management</span></code></a> has been greatly refactored.</p>
<p>Calls to management services in your code now need to use
<code class="docutils literal notranslate"><span class="pre">call_command</span></code>. For example, if you have some test code that calls flush and
load_data:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.core</span> <span class="kn">import</span> <span class="n">management</span>
<span class="n">management</span><span class="o">.</span><span class="n">flush</span><span class="p">(</span><span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">interactive</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="n">management</span><span class="o">.</span><span class="n">load_data</span><span class="p">([</span><span class="s1">&#39;test_data&#39;</span><span class="p">],</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
</pre></div>
</div>
<p>…you’ll need to change this code to read:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.core</span> <span class="kn">import</span> <span class="n">management</span>
<span class="n">management</span><span class="o">.</span><span class="n">call_command</span><span class="p">(</span><span class="s1">&#39;flush&#39;</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">interactive</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="n">management</span><span class="o">.</span><span class="n">call_command</span><span class="p">(</span><span class="s1">&#39;loaddata&#39;</span><span class="p">,</span> <span class="s1">&#39;test_data&#39;</span><span class="p">,</span> <span class="n">verbosity</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="s-subcommands-must-now-precede-options">
<span id="subcommands-must-now-precede-options"></span><h4>Subcommands must now precede options<a class="headerlink" href="#subcommands-must-now-precede-options" title="Permalink to this headline">¶</a></h4>
<p><code class="docutils literal notranslate"><span class="pre">django-admin.py</span></code> and <code class="docutils literal notranslate"><span class="pre">manage.py</span></code> now require subcommands to precede
options. So:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> django-admin.py --settings<span class="o">=</span>foo.bar runserver
</pre></div>
</div>
<p>…no longer works and should be changed to:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span> django-admin.py runserver --settings<span class="o">=</span>foo.bar
</pre></div>
</div>
</div>
</div>
<div class="section" id="s-syndication">
<span id="syndication"></span><h3>Syndication<a class="headerlink" href="#syndication" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-feed-init-has-changed">
<span id="feed-init-has-changed"></span><h4><code class="docutils literal notranslate"><span class="pre">Feed.__init__</span></code> has changed<a class="headerlink" href="#feed-init-has-changed" title="Permalink to this headline">¶</a></h4>
<p>The <code class="docutils literal notranslate"><span class="pre">__init__()</span></code> method of the syndication framework’s <code class="docutils literal notranslate"><span class="pre">Feed</span></code> class now
takes an <code class="docutils literal notranslate"><span class="pre">HttpRequest</span></code> object as its second parameter, instead of the feed’s
URL. This allows the syndication framework to work without requiring the sites
framework. This only affects code that subclasses <code class="docutils literal notranslate"><span class="pre">Feed</span></code> and overrides the
<code class="docutils literal notranslate"><span class="pre">__init__()</span></code> method, and code that calls <code class="docutils literal notranslate"><span class="pre">Feed.__init__()</span></code> directly.</p>
</div>
</div>
<div class="section" id="s-data-structures">
<span id="data-structures"></span><h3>Data structures<a class="headerlink" href="#data-structures" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-sorteddictfromlist-is-gone">
<span id="sorteddictfromlist-is-gone"></span><h4><code class="docutils literal notranslate"><span class="pre">SortedDictFromList</span></code> is gone<a class="headerlink" href="#sorteddictfromlist-is-gone" title="Permalink to this headline">¶</a></h4>
<p><code class="docutils literal notranslate"><span class="pre">django.newforms.forms.SortedDictFromList</span></code> was removed.
<code class="docutils literal notranslate"><span class="pre">django.utils.datastructures.SortedDict</span></code> can now be instantiated with
a sequence of tuples.</p>
<p>To update your code:</p>
<ol class="arabic simple">
<li>Use <code class="docutils literal notranslate"><span class="pre">django.utils.datastructures.SortedDict</span></code> wherever you were
using <code class="docutils literal notranslate"><span class="pre">django.newforms.forms.SortedDictFromList</span></code>.</li>
<li>Because <code class="docutils literal notranslate"><span class="pre">django.utils.datastructures.SortedDict.copy</span></code> doesn’t
return a deepcopy as <code class="docutils literal notranslate"><span class="pre">SortedDictFromList.copy()</span></code> did, you will need
to update your code if you were relying on a deepcopy. Do this by using
<code class="docutils literal notranslate"><span class="pre">copy.deepcopy</span></code> directly.</li>
</ol>
</div>
</div>
<div class="section" id="s-database-backend-functions">
<span id="database-backend-functions"></span><h3>Database backend functions<a class="headerlink" href="#database-backend-functions" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-database-backend-functions-have-been-renamed">
<span id="database-backend-functions-have-been-renamed"></span><h4>Database backend functions have been renamed<a class="headerlink" href="#database-backend-functions-have-been-renamed" title="Permalink to this headline">¶</a></h4>
<p>Almost <em>all</em> of the database backend-level functions have been renamed and/or
relocated. None of these were documented, but you’ll need to change your code
if you’re using any of these functions, all of which are in <a class="reference internal" href="../topics/db/index.html#module-django.db" title="django.db"><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.db</span></code></a>:</p>
<table class="docutils">
<colgroup>
<col width="43%" />
<col width="57%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Old (0.96)</th>
<th class="head">New (1.0)</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.get_autoinc_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.autoinc_sql</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.get_date_extract_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.date_extract_sql</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.get_date_trunc_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.date_trunc_sql</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.get_datetime_cast_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.datetime_cast_sql</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.get_deferrable_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.deferrable_sql</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.get_drop_foreignkey_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.drop_foreignkey_sql</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.get_fulltext_search_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.fulltext_search_sql</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.get_last_insert_id</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.last_insert_id</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.get_limit_offset_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.limit_offset_sql</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.get_max_name_length</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.max_name_length</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.get_pk_default_value</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.pk_default_value</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.get_random_function_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.random_function_sql</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.get_sql_flush</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.sql_flush</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.get_sql_sequence_reset</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.sequence_reset_sql</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.get_start_transaction_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.start_transaction_sql</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.get_tablespace_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.tablespace_sql</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.quote_name</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.quote_name</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.get_query_set_class</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.query_set_class</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.get_field_cast_sql</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.field_cast_sql</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.get_drop_sequence</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.ops.drop_sequence_sql</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.OPERATOR_MAPPING</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.operators</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.allows_group_by_ordinal</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.features.allows_group_by_ordinal</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.allows_unique_and_pk</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.features.allows_unique_and_pk</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.autoindexes_primary_keys</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.features.autoindexes_primary_keys</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.needs_datetime_string_cast</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.features.needs_datetime_string_cast</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.needs_upper_for_iops</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.features.needs_upper_for_iops</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.supports_constraints</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.features.supports_constraints</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.supports_tablespaces</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.features.supports_tablespaces</span></code></td>
</tr>
<tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">backend.uses_case_insensitive_names</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.features.uses_case_insensitive_names</span></code></td>
</tr>
<tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">backend.uses_custom_queryset</span></code></td>
<td><code class="docutils literal notranslate"><span class="pre">connection.features.uses_custom_queryset</span></code></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Porting your apps from Django 0.96 to 1.0</a><ul>
<li><a class="reference internal" href="#common-changes">Common changes</a><ul>
<li><a class="reference internal" href="#use-unicode">Use Unicode</a></li>
<li><a class="reference internal" href="#models">Models</a><ul>
<li><a class="reference internal" href="#rename-maxlength-to-max-length">Rename <code class="docutils literal notranslate"><span class="pre">maxlength</span></code> to <code class="docutils literal notranslate"><span class="pre">max_length</span></code></a></li>
<li><a class="reference internal" href="#replace-str-with-unicode">Replace <code class="docutils literal notranslate"><span class="pre">__str__</span></code> with <code class="docutils literal notranslate"><span class="pre">__unicode__</span></code></a></li>
<li><a class="reference internal" href="#remove-prepopulated-from">Remove <code class="docutils literal notranslate"><span class="pre">prepopulated_from</span></code></a></li>
<li><a class="reference internal" href="#remove-core">Remove <code class="docutils literal notranslate"><span class="pre">core</span></code></a></li>
<li><a class="reference internal" href="#replace-class-admin-with-admin-py">Replace <code class="docutils literal notranslate"><span class="pre">class</span> <span class="pre">Admin:</span></code> with <code class="docutils literal notranslate"><span class="pre">admin.py</span></code></a></li>
<li><a class="reference internal" href="#example">Example</a></li>
</ul>
</li>
<li><a class="reference internal" href="#the-admin">The Admin</a><ul>
<li><a class="reference internal" href="#use-new-inline-syntax">Use new inline syntax</a></li>
<li><a class="reference internal" href="#simplify-fields-or-use-fieldsets">Simplify <code class="docutils literal notranslate"><span class="pre">fields</span></code>, or use <code class="docutils literal notranslate"><span class="pre">fieldsets</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#urls">URLs</a><ul>
<li><a class="reference internal" href="#update-your-root-urls-py">Update your root <code class="docutils literal notranslate"><span class="pre">urls.py</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#views">Views</a><ul>
<li><a class="reference internal" href="#use-django-forms-instead-of-newforms">Use <code class="docutils literal notranslate"><span class="pre">django.forms</span></code> instead of <code class="docutils literal notranslate"><span class="pre">newforms</span></code></a></li>
<li><a class="reference internal" href="#handle-uploaded-files-using-the-new-api">Handle uploaded files using the new API</a></li>
<li><a class="reference internal" href="#work-with-file-fields-using-the-new-api">Work with file fields using the new API</a></li>
<li><a class="reference internal" href="#use-paginator-instead-of-objectpaginator">Use <code class="docutils literal notranslate"><span class="pre">Paginator</span></code> instead of <code class="docutils literal notranslate"><span class="pre">ObjectPaginator</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#templates">Templates</a><ul>
<li><a class="reference internal" href="#learn-to-love-autoescaping">Learn to love autoescaping</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#less-common-changes">Less-common changes</a><ul>
<li><a class="reference internal" href="#signals">Signals</a></li>
<li><a class="reference internal" href="#comments">Comments</a></li>
<li><a class="reference internal" href="#template-tags">Template tags</a><ul>
<li><a class="reference internal" href="#spaceless-tag"><code class="docutils literal notranslate"><span class="pre">spaceless</span></code> tag</a></li>
</ul>
</li>
<li><a class="reference internal" href="#local-flavors">Local flavors</a><ul>
<li><a class="reference internal" href="#u-s-local-flavor">U.S. local flavor</a></li>
</ul>
</li>
<li><a class="reference internal" href="#sessions">Sessions</a><ul>
<li><a class="reference internal" href="#getting-a-new-session-key">Getting a new session key</a></li>
</ul>
</li>
<li><a class="reference internal" href="#fixtures">Fixtures</a><ul>
<li><a class="reference internal" href="#loading-a-row-no-longer-calls-save">Loading a row no longer calls <code class="docutils literal notranslate"><span class="pre">save()</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#settings">Settings</a><ul>
<li><a class="reference internal" href="#better-exceptions">Better exceptions</a></li>
<li><a class="reference internal" href="#login-url-has-moved"><code class="docutils literal notranslate"><span class="pre">LOGIN_URL</span></code> has moved</a></li>
<li><a class="reference internal" href="#append-slash-behavior-has-been-updated"><code class="docutils literal notranslate"><span class="pre">APPEND_SLASH</span></code> behavior has been updated</a></li>
</ul>
</li>
<li><a class="reference internal" href="#smaller-model-changes">Smaller model changes</a><ul>
<li><a class="reference internal" href="#different-exception-from-get">Different exception from <code class="docutils literal notranslate"><span class="pre">get()</span></code></a></li>
<li><a class="reference internal" href="#lazydate-has-been-fired"><code class="docutils literal notranslate"><span class="pre">LazyDate</span></code> has been fired</a></li>
<li><a class="reference internal" href="#decimalfield-is-new-and-floatfield-is-now-a-proper-float"><code class="docutils literal notranslate"><span class="pre">DecimalField</span></code> is new, and <code class="docutils literal notranslate"><span class="pre">FloatField</span></code> is now a proper float</a></li>
</ul>
</li>
<li><a class="reference internal" href="#internationalization">Internationalization</a><ul>
<li><a class="reference internal" href="#django-views-i18n-set-language-now-requires-a-post-request"><code class="docutils literal notranslate"><span class="pre">django.views.i18n.set_language()</span></code> now requires a POST request</a></li>
<li><a class="reference internal" href="#is-no-longer-in-builtins"><code class="docutils literal notranslate"><span class="pre">_()</span></code> is no longer in builtins</a></li>
</ul>
</li>
<li><a class="reference internal" href="#http-request-response-objects">HTTP request/response objects</a><ul>
<li><a class="reference internal" href="#dictionary-access-to-httprequest">Dictionary access to <code class="docutils literal notranslate"><span class="pre">HttpRequest</span></code></a></li>
<li><a class="reference internal" href="#accessing-httpresponse-headers">Accessing <code class="docutils literal notranslate"><span class="pre">HTTPResponse</span></code> headers</a></li>
</ul>
</li>
<li><a class="reference internal" href="#generic-relations">Generic relations</a><ul>
<li><a class="reference internal" href="#generic-relations-have-been-moved-out-of-core">Generic relations have been moved out of core</a></li>
</ul>
</li>
<li><a class="reference internal" href="#testing">Testing</a><ul>
<li><a class="reference internal" href="#django-test-client-login-has-changed"><code class="docutils literal notranslate"><span class="pre">django.test.Client.login()</span></code> has changed</a></li>
</ul>
</li>
<li><a class="reference internal" href="#management-commands">Management commands</a><ul>
<li><a class="reference internal" href="#running-management-commands-from-your-code">Running management commands from your code</a></li>
<li><a class="reference internal" href="#subcommands-must-now-precede-options">Subcommands must now precede options</a></li>
</ul>
</li>
<li><a class="reference internal" href="#syndication">Syndication</a><ul>
<li><a class="reference internal" href="#feed-init-has-changed"><code class="docutils literal notranslate"><span class="pre">Feed.__init__</span></code> has changed</a></li>
</ul>
</li>
<li><a class="reference internal" href="#data-structures">Data structures</a><ul>
<li><a class="reference internal" href="#sorteddictfromlist-is-gone"><code class="docutils literal notranslate"><span class="pre">SortedDictFromList</span></code> is gone</a></li>
</ul>
</li>
<li><a class="reference internal" href="#database-backend-functions">Database backend functions</a><ul>
<li><a class="reference internal" href="#database-backend-functions-have-been-renamed">Database backend functions have been renamed</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="1.0.html"
                        title="previous chapter">Django 1.0 release notes</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="0.96.html"
                        title="next chapter">Django version 0.96 release notes</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/releases/1.0-porting-guide.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Jun 03, 2019</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="1.0.html" title="Django 1.0 release notes">previous</a>
     |
    <a href="index.html" title="Release notes" accesskey="U">up</a>
   |
    <a href="0.96.html" title="Django version 0.96 release notes">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>